﻿using System;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using WeChat.Entity;

namespace WeChat.EntityFramework.Mapping
{
    /// <summary>
    /// 用户角色 Mapping
    /// </summary>
    public class UserRolesMapping : WeChatBaseMap<UserRoles, int>
    {
        public override void MapperConfigure(EntityTypeBuilder<UserRoles> builder)
        {
            builder.HasOne(a => a.User).WithMany().HasForeignKey(a => a.UserId);
            builder.HasOne(a => a.Role).WithMany().HasForeignKey(a => a.RoleId);

            builder.HasData(new UserRoles()
            {
                Id = 1,
                RoleId = 1,
                UserId = 1,
                CreatedTime = DateTime.Now,
                IsActivate = true
            });
        }
    }
}
